import 'package:flutter/material.dart';
import 'package:flutter_study/activity/AndroidActivity.dart';
import 'package:flutter_study/eventbus/eventbus.dart';
import 'package:flutter_study/flutter_datetime_picker/datetime.dart';
import 'package:flutter_study/image_picker/imagepicker.dart';
import 'package:flutter_study/mvp/view/contacts_page.dart';
import 'package:flutter_study/mvvm/view/StoryPage.dart';
import 'package:flutter_study/permission/permission.dart';
import 'package:flutter_study/push/PushPage.dart';
import 'package:flutter_study/refresh/refresh.dart';
import 'package:flutter_study/shared_preferences/sharedp.dart';
import 'package:flutter_study/sqflite/sqflite.dart';
import 'package:flutter_study/urllaunch/urllaunch.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  final String url3 = "rtmp://202.69.69.180:443/webcast/bshdlive-pc";
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      routes: <String, WidgetBuilder>{
        '/sqflite': (BuildContext context) => SqflitePage(title: 'Sqflite'),
        '/sharedp': (BuildContext context) => SharedPre(title: '键值对储存'),
        '/datetime': (BuildContext context) => DateTimePicker(title: '日期时间选择器'),
        '/loadmore': (BuildContext context) => LoadMorePage(title: '加载更多'),
        '/image': (BuildContext context) => ImagePickerPage(title: '图片'),
        '/permision': (BuildContext context) => PermisionPage(title: '权限'),
        '/eventbus': (BuildContext context) => EventBusPage(title: 'EventBus'),
        '/gobd': (BuildContext context) => UrlLaunch(title: '去百度'),
        '/mvvm': (BuildContext context) => StoryPage(),
        '/mvp': (BuildContext context) => ContactsPage(),
        //目前三方插件仅仅支持android
//        '/push': (BuildContext context) => PlayerDemo(url3),
        '/startactivity': (BuildContext context) => GoAndroidActivity(title:'启动AndroidActivity'),
      },
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: ListView(
          children: <Widget>[
            //sqflite
            RaisedButton(
              onPressed: () {
                Navigator.pushNamed(context, '/sqflite');
              },
              child: Text('Flutter之Sqflite'),
            ),
            RaisedButton(
              onPressed: () {
                Navigator.pushNamed(context, '/sharedp');
              },
              child: Text('Flutter之shared_preferences存储'),
            ),
            RaisedButton(
              onPressed: () {
                Navigator.pushNamed(context, '/datetime');
              },
              child: Text('Flutter之日期时间选择器'),
            ),
            RaisedButton(
              onPressed: () {
                Navigator.pushNamed(context, '/loadmore');
              },
              child: Text('Flutter之上拉、下拉'),
            ),
            RaisedButton(
              onPressed: () {
                Navigator.pushNamed(context, '/image');
              },
              child: Text('Flutter之图片'),
            ),
            RaisedButton(
              onPressed: () {
                Navigator.pushNamed(context, '/permision');
              },
              child: Text('Flutter之权限'),
            ),
            RaisedButton(
              onPressed: () {
                Navigator.pushNamed(context, '/eventbus');
              },
              child: Text('Flutter之EventBus'),
            ),
            RaisedButton(
              onPressed: () {
                Navigator.pushNamed(context, '/gobd');
              },
              child: Text('Flutter之url跳转'),
            ),
            RaisedButton(
              onPressed: () {
                Navigator.pushNamed(context, '/mvvm');
              },
              child: Text('Flutter之MVVM'),
            ),
            RaisedButton(
              onPressed: () {
                Navigator.pushNamed(context, '/mvp');
              },
              child: Text('Flutter之MVP'),
            ),
            RaisedButton(
              onPressed: () {
                Navigator.pushNamed(context, '/push');
              },
              child: Text('Flutter之Push'),
            ),
            RaisedButton(
              onPressed: () {
                Navigator.pushNamed(context, '/startactivity');
              },
              child: Text('Flutter之启动AndroidActivity'),
            )
          ],
        ),
      ),
    );
  }
}
